package com.atung.provider;

import java.util.Objects;

import org.apache.ibatis.jdbc.SQL;

import com.atung.model.BusSchoolBusPayment;

public class BusSchoolBusPaymentProvide {

	public String saveBusSchoolBusPaymentProvider(BusSchoolBusPayment busSchoolBusPayment){
		
		return new SQL(){
			{
				INSERT_INTO("bus_school_bus_payment");
				
				VALUES("id", "#{id}");
				VALUES("open_id", "#{openId}");
				VALUES("rout_publish_id", "#{routPublishId}");
				VALUES("platform_order_number", "#{platformOrderNumber}");
				VALUES("order_status", "#{orderStatus}");
				VALUES("order_payable_money", "#{orderPayableMoney}");
				VALUES("order_create_time", "#{orderCreateTime}");
				if(Objects.nonNull(busSchoolBusPayment.getIsDelect())){
					VALUES("is_delect", "#{isDelect}");
				}
				VALUES("creation_time", "#{creationTime}");
				VALUES("modification_time", "#{modificationTime}");	
				
			}
		}.toString();
	}
	
	public String updateBusSchoolBusPaymentProvider(BusSchoolBusPayment busSchoolBusPayment){
		
		return new SQL(){
			{
			
				UPDATE("bus_school_bus_payment");
				SET("payment_order_number=#{paymentOrderNumber}");
				if(Objects.nonNull(busSchoolBusPayment.getOrderPayTime())){
					SET("order_pay_time=#{orderPayTime}");
				}
				SET("order_status=#{orderStatus}");
				if(Objects.nonNull(busSchoolBusPayment.getOrderPayMoney())){
					SET("order_pay_money=#{orderPayMoney}");
				}
				
				if(Objects.nonNull(busSchoolBusPayment.getIsDelect())){
					SET("is_delect=#{isDelect}");
				}
				SET("modification_time=#{modificationTime}");	
				
				WHERE("platform_order_number=#{platformOrderNumber}");
				
				
			}
		}.toString();
	}
}
